﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace SKG.DXF.Ktx.Danhmuc.Phong
{
    public partial class FrmCapnhatGianuoc : DevExpress.XtraEditors.XtraForm
    {
        SKG.DAL.Ktx_GianuocDAL _dal = new DAL.Ktx_GianuocDAL();

        public FrmCapnhatGianuoc() 
        {
            InitializeComponent();
        }

        private void FrmCapnhatGianuoc_Load(object sender, EventArgs e)
        { 
            txtGiamoi.Focus();

            DataTable dtb = _dal.Select();
            txtGiahientai.Text = dtb.Rows[0]["Gia"] + "";
        }

        private void btnThaydoi_Click(object sender, EventArgs e)
        {
            var o = new DAL.Entities.Ktx_Gianuoc()
            {
                Gia = Convert.ToDecimal(txtGiamoi.Text)
            };

            var oki = _dal.Insert(o);
            if (oki == null) XtraMessageBox.Show("Lỗi, cập nhật thất bại !", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            else
            {
               DialogResult result = XtraMessageBox.Show("Cập nhật thành công !", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
               if (result == DialogResult.OK)
                   this.Close();
            }
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}